import { getMenu } from '@/services/menu';

let menuCache: any[] | null = null;          // ① 同一份内存

/** 第一次异步拉取 */
export async function getMenuTree() {
  if (menuCache) return menuCache;
  const res = await getMenu();
  menuCache = res.menuList; // 只拿数组
  return menuCache;
}


/** 后面同步读 */
export function getMenuCacheSync  (){
  return menuCache ?? [] ;
}